package com.example.leetdemo.process;

import com.example.leetdemo.utils.DateUtils;

import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class Solution698 {

    public boolean canPartitionKSubsets(int[] nums, int k) {

        Integer sum = Arrays.stream(nums).sum();
        Arrays.sort(nums);
        if (nums[nums.length - 1] > sum / k || sum % k > 0) {
            return false;
        }
        Map<Integer, Integer> map = new HashMap<>();
        for (int i = 0; i < nums.length; i++) {
            map.put(nums[i], map.getOrDefault(nums[i], 1));
        }
        Integer count = k, value = sum / k;
        k -= map.getOrDefault(value, 0);
        Set<Integer> keys = map.keySet();

        for (Integer key : keys) {
            if (key == 0) {
                continue;
            }
            if (key <= value && map.get(key) > 0) {

            }
        }
        if (count > 0 && map.getOrDefault(0, 0) < count) {
            return false;
        }
        return true;
    }

    private boolean dps(Map<Integer, Integer> map, int key, int values, Integer count) {
        if (map.containsKey(values - key)) {
            count++;
            return true;
        } else {
            for (int i = 1; i < values - key; i++) {

            }
        }
        return false;
    }

    public static void main(String[] args) {
        LocalDateTime now = LocalDateTime.now();
        System.err.println(DateUtils.localDateTimeToMilli(now) / 10000);
        System.err.println(DateUtils.format(now, "YYYYMMdd hh:mm:ss"));
    }
}
